import {createRouter, createWebHistory, RouteRecordRaw} from 'vue-router';


// 动态生成
export const constantRoutes: Array<RouteRecordRaw> = [
    {
        path: '/login',
        name: 'login',
        component: () => import("@/views/login/index.vue")
    },
    {
        path: '/',
        component: () => import("@/layout/index.vue"),
        redirect: '/dashboard',
        children: [
            {
                path: '/dashboard',
                component: () => import("@/views/dashboard/index.vue"),
                name: 'dashboard',
                meta: {
                    title: '首页',
                    icon: 'HomeFilled'
                }
            }
        ]
    },
    {
        path: '/center',
        component: () => import('@/layout/index.vue'),
        redirect: '/userCenter',
        children: [
            {
                path: '/userCenter',
                component: () => import('@/views/userCenter/index.vue'),
                name: 'userCenter',
                meta: {
                    hidden: true,
                    title: '个人中心',
                    icon: 'User',
                },
            },
        ]
    },
    {
        path: '/system',
        component: () => import('@/layout/index.vue'),
        redirect: '/dictData',
        children: [
            {
                path: '/dictData/:type',
                component: () => import('@/views/system/dictData/index.vue'),
                name: 'dictData',
                meta: {
                    hidden: true,
                    title: '字典数据',
                    icon: 'User',
                }
            }
        ]
    },
    {
        path: '/software',
        component: () => import('@/layout/index.vue'),
        redirect: '/software/softwareForm',
        children: [
            // 新增页面（不传 id）
            {
                path: '/softwareForm',
                component: () => import('@/views/compute/softwarePlan/softwareForm.vue'),
                name: 'softwareFormCreate',
                meta: {
                    title: '新增软件核价单',
                    icon: 'Collection',
                }
            },
            // 编辑页面（带 id）
            {
                path: '/softwareForm/:id',
                component: () => import('@/views/compute/softwarePlan/softwareForm.vue'),
                name: 'softwareFormEdit',
                meta: {
                    hidden: true,
                    title: '编辑软件核价单',
                    icon: 'Collection',
                }
            }
        ]
    },


    {
        path: '/costForm',
        component: () => import('@/layout/index.vue'),
        redirect: '/costForm',
        children: [
            // 新增页面（不传 id）
            {
                path: '/costForm',
                component: () => import('@/views/compute/costPlan/costForm.vue'),
                name: 'costFormCreate',
                meta: {
                    title: '新增电控成本单',
                    icon: 'Collection',
                }
            },
            // 编辑页面（带 id）
            {
                path: '/costForm/:id',
                component: () => import('@/views/compute/costPlan/costForm.vue'),
                name: 'costFormEdit',
                meta: {
                    hidden: true,
                    title: '编辑电控成本单',
                    icon: 'Collection',
                }
            }
        ]
    },
    {
        path: '/form',
        component: () => import('@/layout/index.vue'),
        redirect: '/form/category',
        children: [
            {
                path: 'category/:type/:id?',
                component: () => import('@/views/category/form.vue'),
                name: 'categoryForm',
                meta: {
                    hidden: true,
                    title: '表单操作',
                    icon: 'User',
                    keepAlive: true,
                },
            },
        ]
    },
    // 工具模块路由
    {
        path: '/tools',
        component: () => import('@/layout/index.vue'),
        redirect: '/tools/formulaConvert',
        children: [
            // Excel公式转换器页面
            {
                path: '/tools/formulaConvert',
                component: () => import('@/views/tools/formulaConvert/index.vue'),
                name: 'formulaConvert',
                meta: {
                    title: 'Excel公式转换器',
                    icon: 'Setting',
                }
            },
            // Excel公式转换演示页面
            {
                path: '/tools/formulaConvert/demo',
                component: () => import('@/views/tools/formulaConvert/demo.vue'),
                name: 'formulaConvertDemo',
                meta: {
                    title: '公式转换演示',
                    icon: 'Histogram',
                }
            }
        ]
    },
    // 计算模块统一路由
    {
        path: '/compute',
        component: () => import('@/layout/index.vue'),
        redirect: '/compute/budgetSheet',
        children: [
            // 预算单列表页
            {
                path: '/compute/budgetSheet',
                component: () => import('@/views/compute/budgetSheet/index.vue'),
                name: 'budgetSheet',
                meta: {
                    title: '预算单管理',
                    icon: 'DocumentCopy',
                }
            },
            // 设备核价列表页
            {
                path: '/compute/devicePricing',
                component: () => import('@/views/compute/devicePricing/index.vue'),
                name: 'devicePricing',
                meta: {
                    title: '设备核价管理',
                    icon: 'Tools',
                }
            },

            // 新增预算单页面
            {
                path: '/compute/budgetSheet/form',
                component: () => import('@/views/compute/budgetSheet/budgetSheetForm.vue'),
                name: 'budgetSheetFormCreate',
                meta: {
                    hidden: true,
                    title: '新增预算单',
                    icon: 'Plus',
                }
            },
            // 编辑预算单页面
            {
                path: '/compute/budgetSheet/form/:id',
                component: () => import('@/views/compute/budgetSheet/budgetSheetForm.vue'),
                name: 'budgetSheetFormEdit',
                meta: {
                    hidden: true,
                    title: '编辑预算单',
                    icon: 'Edit',
                }
            },
            // 新增设备核价页面
            {
                path: '/compute/devicePricing/form',
                component: () => import('@/views/compute/devicePricing/devicePricingForm.vue'),
                name: 'devicePricingFormCreate',
                meta: {
                    hidden: true,
                    title: '新增设备核价',
                    icon: 'Plus',
                }
            },
            // 编辑设备核价页面
            {
                path: '/compute/devicePricing/form/:id',
                component: () => import('@/views/compute/devicePricing/devicePricingForm.vue'),
                name: 'devicePricingFormEdit',
                meta: {
                    hidden: true,
                    title: '编辑设备核价',
                    icon: 'Edit',
                }
            },
            // 查看设备核价详情页面
            {
                path: '/compute/devicePricing/detail/:id',
                component: () => import('@/views/compute/devicePricing/devicePricingForm.vue'),
                name: 'devicePricingDetail',
                meta: {
                    hidden: true,
                    title: '设备核价详情',
                    icon: 'View',
                },
                props: (route) => ({
                    display: 'true'
                })
            },
            // 历史预算单列表页
            {
                path: '/compute/historicalQuotation/index',
                component: () => import('@/views/compute/historicalQuotation/index.vue'),
                name: 'historicalQuotation',
                meta: {
                    title: '历史预算单',
                    icon: 'Document',
                }
            },
            // 历史预算单详情页
            {
                path: '/compute/historicalQuotation/detail/:id',
                component: () => import('@/views/compute/historicalQuotation/detail.vue'),
                name: 'historicalQuotationDetail',
                meta: {
                    hidden: true,
                    title: '历史预算单详情',
                    icon: 'View',
                }
            }
        ]
    },
    // 报价单路由
    {
        path: '/pricing',
        component: () => import('@/layout/index.vue'),
        redirect: '/pricing/index',
        children: [
            // 报价单管理页面
            {
                path: '/pricing/index',
                component: () => import('@/views/pricing/index.vue'),
                name: 'pricingManagement',
                meta: {
                    title: '报价单管理',
                    icon: 'DocumentChecked',
                }
            }
        ]
    },
    // 规格详情路由
    // {
    //     path: '/specificationDetail',
    //     component: () => import('@/layout/index.vue'),
    //     redirect: '/specificationDetail',
    //     children: [
    //         {
    //             path: '/specificationDetail',
    //             component: () => import('@/views/compute/specificationDetail/index.vue'),
    //             name: 'specificationDetail',
    //             meta: {
    //                 title: '规格详情管理',
    //                 icon: 'List',
    //             }
    //         }
    //     ]
    // },
];

// 创建路由实例
const router = createRouter({
    history: createWebHistory(),
    routes:constantRoutes
});

export default router;
